include("shared.lua")

local Chat = {
	Tree1 = { "I got some drugs for ye'", function() Msg( "tree1" ) end },
	Tree2 = { "I best be out of here!", function() Msg( "tree2" ) DermaFrame:SetVisible( false ) end }
}

function NPCMenu()	

DermaFrame = vgui.Create( "DFrame" )
DermaFrame:SetSize( 600, 150 )
DermaFrame:SetPos( ScrW() / 2 - DermaFrame:GetWide() / 2, ScrH() - DermaFrame:GetTall() - 10 )
DermaFrame:SetTitle( "Chat Menu" )
DermaFrame:SetVisible( true )
DermaFrame:SetDraggable( false )
DermaFrame:ShowCloseButton( false )
DermaFrame:MakePopup()

local DermaList = vgui.Create( "DPanelList", DermaFrame )
DermaList:SetPos( 10, 32 )
DermaList:SetSize( DermaFrame:GetWide() - 20, DermaFrame:GetTall() - 107 )
DermaList:SetSpacing( 3 )
DermaList:EnableHorizontal( false )
DermaList:EnableVerticalScrollbar( true )

local DermaLabel = vgui.Create( "DLabel", DermaList )
DermaLabel:SetText( "What do you want?" )
DermaLabel:SizeToContents()
DermaLabel:SetWrap( true )
DermaLabel:Center()

local DermaList2 = vgui.Create( "DPanelList", DermaFrame )
DermaList2:SetPos( 10, 82 )
DermaList2:SetSize( DermaFrame:GetWide() - 20, DermaFrame:GetTall() - 92 )
DermaList2:SetSpacing( 0 )
DermaList2:EnableHorizontal( false )
DermaList2:EnableVerticalScrollbar( true )

	 for k,v in pairs( Chat ) do 

		local DermaButton = vgui.Create( "DButton", DermaList2 )
		DermaButton:SetSize( DermaList:GetWide() - 20, 20 )
		DermaButton:SetPos( 10, 3 )
		DermaButton:SetText( v[1] )
		DermaButton.DoClick = v[2]
		DermaList2:AddItem( DermaButton )
	end
end

usermessage.Hook("DrugDealerUsed", NPCMenu)